<?php	
include "../functions.php";
try{
   $pdo = new Pdo("mysql:host=localhost;dbname=c70","root","admin888");
   //设置字符集
   $pdo->query("set names utf8");
   //设置错误属性,ERRMODE_EXCEPTION抛出异常错误，会被catch接收到
   $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
   //查询
   $res = $pdo->query("select * from stu");
   //接受结果集
   $rows = $res->fetchAll(PDO::FETCH_ASSOC);
   p($rows);
}catch(PDOException $e){
    echo "<h2 style='color:red'>".$e->getMessage()."</h2>";
}

























